﻿using Architecture.API.Application.TraceabilityCommand.EnterpriseCommand;
using MediatR;
using Traceability.Domain.Service.EnterpriseServices;
using Traceability.Domain.TraceabilityDto;

namespace Architecture.API.Application.TraceabilityCommandHandler.EnterpriseCommandHandler
{
    /// <summary>
    /// 
    /// </summary>
    public class ShowEnterpriseCommandHandler : IRequestHandler<ShowEnterpriseCommand, List<EnterpriseDto>>
    {
        /// <summary>
        /// 企业服务
        /// </summary>
        protected readonly IEnterpriseService enterpriseService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="enterpriseService">企业服务</param>
        public ShowEnterpriseCommandHandler(IEnterpriseService enterpriseService)
        {
            this.enterpriseService = enterpriseService;
        }

        /// <summary>
        /// 企业信息服务列表
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消标记</param>
        /// <returns>返回企业信息列表</returns>
        public async Task<List<EnterpriseDto>> Handle(ShowEnterpriseCommand request, CancellationToken cancellationToken)
        {
            return await enterpriseService.GetEnterpriseList();
        }
    }
}
